#include <algorithm>
#include <vector>
using namespace std;
int hIndex(vector<int> &citations) {
  sort(citations.begin(), citations.end(), [](int a, int b) { return a > b; });
  int h = 0;
  for (int i = 0; i < citations.size(); ++i) {
    if (citations[i] >= h + 1) {
      h++;
    } else {
      break;
    }
  }
  return h;
}